package com.qdu.reducer;

import com.qdu.bean.bikeWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class rentPerRestHourReducer extends Reducer<Text, bikeWritable,Text, bikeWritable> {
    bikeWritable bw3 = new bikeWritable();

    @Override
    protected void reduce(Text key, Iterable<bikeWritable> values, Context context) throws IOException, InterruptedException {
        int casual=0;
        int registered=0;
        int count=0;
        int sum=0;
        for (bikeWritable b : values) {
            casual+=b.getCasual();
            registered+=b.getRegistered();
            count+=b.getCount();
            sum++;
        }
        bw3.set2(casual/sum,registered/sum,count/sum);
        context.write(key,bw3);
    }
}
